import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
import { BaseEntity } from './baseentity';
import { ADesign } from './design.entity';
import { AViewScope } from './viewscope.entity';

@Entity()
export class AView extends BaseEntity {
  @Column({ nullable: false })
  name: string;

  @Column({ nullable: false })
  width: number;

  @ManyToOne(() => ADesign, (a) => a.views, { onDelete: 'CASCADE' })
  design: ADesign;

  // @ManyToMany(() => AScope, (a) => a.views)
  // @JoinTable({ name: 'a_view_scope' })
  // scopes: AScope[];
  @OneToMany(() => AViewScope, (a) => a.view, { cascade: true })
  viewscopes: AViewScope[];

  @Column({ nullable: true })
  order: number;
}
